fix for-loop calling done() on every iteration