added win/lose function to make code less repetitive.