small refactoring
integrate lua script