rewrite codebase