add flatten support