updated for determining the end of a game but did not work