Added function to check if player wins