dependency merging logic