Added end conditions to win and lose.