updated algorithm to work with the changes to the team class