better handling of distances