updated checkWinner function