added win and end condition