Trying new distance function