Changed distance calculation method