Adjusted the distance calculation (again)