refactor save