Fixed bug when locating template