Reorganize the command logic