Changed distance calculation