code copy from luaxml