fixing bugs in merge