replace change_callback by flatten_and_store