improved logic to detect if player is on the ground