fixed findTemplate implementation