array merge function