refactor getNextWord to return lowercase