made distance function helper function.