refactor win logic.