Code with correct syntax for .flatten