Refactor save_auto_state