improved middleware, params are forwarded properly