refactor word collecting