This is the merge routine.