refactors word count