Refactor the command match function to "Switch".