added detection of win or lose