this is a lot of code for inside "another" middleware function, can we make generating the metaTags its own function somehow?