merge function tested