refactored word-count