implement merging