Improve script detection