added min_distance search algo