improve script resiliency