refactor to enable persistence