removed a distance calculation bug