Proper way to compute the distance.