code to check for winner, and end-game code