confirm distance function