improved getTasksToBeFinished_JEDI to avoid row lock contention