Update merge function