basic merge code