simplify sum_dist functions