Revert "use flatten"

This reverts commit f9aca7fcc79c9f2246f2816f3d6c068f8abf5ed1.