Added distance following algorithm.