fix order of middleware