add count_frequency method and test