finish alg_final, should add time measurement later