Update for calc_distance

Needs review.