wouldn't forEach try to iterate over element properties if `element` is not an array? I suspect that we need an isArray check here