completed a part of the algorithm