fixed bugs in merge