reorganised lua a bit