added logic for team win check