refactor templates to simplify