created function to calculate distance between two pairs of latitudes and longitudes