a bug in reduce_distance was fixed