document saving and modify state