added code to clamp the player