added countFreq() functionality