updated to automatically rewrite tags for all templates