CalculateDistance function added