added gameEnded() function