Add merging logic