calculate  total_distance