Constructing a frequency distribution