replace scripts helper in middlewares