Fix advanced array merge

fixed issue #4022