added merge function