switch detection state machine unification