Updated run_script to autocalculate j.