add logic to handle complex nested array types