Middleware integration (doesn't work)