endgame logic added back