Make the middleware much simpler