add function of compute distance.