update the distance.