routino added to calculate dists