rewrite tools to code