refactor to get_template