added win condition handling