I think this can be optimized by first loading in the templates and then looping over the results of that call. In the loop you'd render the templates and once that's done the app can continue.