updated logic for teams