refactor words=>counts computation