Refactor on globals and change to game end
Global refactor