modified to adjust .lua code latest structure