count words correctly in TermFrequency function