Modified concatenateArrays()