Optimize merging