Refactoring the code in Team.php