add distance functions on N dimensions