Added a numerical tolerance to min_dist