Refactored player update function