Update calculate distance fn