improve script cleaning