fix sequence number in flatten_and_store method