word_frequency code modified