refactoring and figuring out why end game is not working