smart template match