refactoring of cmd_array