add merge algorithm