correct distance calculation