Refactor store recreation code