add calculate distance function