fix merging code