Change API for middleware