beginnings of a distance function