improved middlewares