fixed a few errors in the merging alg; added alg caption