Some changes to calcDist