Fix undefined distance.