change the logic that checks whether a job is finished or not.
endTime always not null so not worked expectedly.