change definition of distance function derivative
..