This is the source of the bug.  The translation from the python `not new_done` should be `isempty(new_done)` not `!isempty(new_done)`.