Fixing condition in run_jobs to prevent infinite loop