Adjust distance calculation