refactor for scripting support