cleanup rewrite