remove intermediary function and simplify run_cmd process