I'm doing that and runs better in that order, but still repeating sometimes (i.e. picking instances without the right instance variable).
Is there a way to detect if there is no instance with the right variable at all? i.e., can I count the result of a "compare instance variable"?
If I can't, then I'll add a counter to detect if all instances have the variable already set.