introduced a new intermediate datastructure to hold records and counts of records