Added minDistance method and tested.