ADD STATE SAVING AND RESTORE