smarter finding of templates