// added distance function