added state machine written in Lua