flattening arrays with reduce