Working euclidean distance calculation