updated cleanup method