rewrite evaluation code