Added support for middlewares