Fix change state

Fix issue #377