Rewrite tern.