added better cleanup