Fix counting bug in termFrequency