saves the state