put done() in the right place, better logging