fixed cleanup method