fixed various bugs, included 'while' statement to run multiple jobs