rewrite templates