refactor as templates