add calculate distance function and db functions