Added algorithm for determining which processes need to merge