Code refactoring: use the new run_cmd and avoid code duplication.