cleanup in the _work function