move logic from word_count method to new methods