Middleware fix