added count_frequency method