refactor template selection in extract