fixed some bugs while merging