distance function correction