refact lua runtime