constructing frequency distributions