Added Dist Algo code