Fixing flatten()