This while loop may be unnecessary since the outer loop can check the same thing. Plus that it may end up looping indefinitely if the tasks left in the task log is not enough to increase the ratio over the threshold.