refactor templates structure