Refactored the hangman game code