added connection cleaning code