changed within distance function to return logical the same size as input points, instead of index of true values.