put cleanup stuff into a separate fct