create merge function