refactored hangman