updated merging procedure