added template caching