Start of new merging algorithm