refactored player's code