Constructing a frequency table