refactor for more efficient save