better cleanup method