replace store by flatten_and_store callback