optimized template fetching