moving things from C to lua