Refactoring the code in TeamGame.php