rewrite redundant codes