finish alg.4