fix a bug in merging