added if else statement to VectorizedTo3DArray