refactoring PUT method in change_word