Use flatten correctly