cleanup rc function