merge the segments