Fixed closing substate
Added switch state listener