add fields_rec, flatten_rec