extracted merging stuff out of process