Refactoring the code in Player.php