begin to build merge function