add flatten and flatMap