I was hoping we could convert this to a middleware