begin savestate logic