flatten now uses custom reverse