Refactoring word fetching logic.