fill in ComputeDistance and tested