refactoring dequeueWord