Change from Python to Lua code