added distance calculation functionality. simple distance function and distance helper functions