refactoring
added win condition