Refactor hangman