Some refactoring on the word reverser