bug fix. now it always saves the state.