Rewrite bad code