upgraded to support latest connect middlewares