some refactor in execute_cmd