REF: simplify code for merging