complete logic for command switch