Refactoring the code in GameData.php