Refactor run_scripts