Updated merge code