rewrite template