better cleanup in error case