min_avg_dist added