add Middleware function