(untested incomplete) implementing the merge process