externalize template finder algorithmn