restore and refactor