define a lowest_distance value instead of using a max number of thread