flatten before map