complete logic for command switch-deactivate