Templatized second loop.