refactored lua compile mechanism