Added a small check to see if distance is decreasing.