fix bug in state handling