Added team number input to team loop function