refactor; add save and recover