consolodate distance functions