refactored word counting
words and count_frequency are now more modular