if we can do this as middleware, then that would be better. but if it's only relevant in this particular call (and nowhere else) we can keep it here.