utils code for lua