flatten nesting