fix condition of state change