Optimized code and added way to get the player case independent