Working but MapMiddleware throwing exceptions