Template refactor