set the state correctly