fixed some bugs with the merging