add flatten flag on conversion