added support for multiple middlewares