Refactoring scripting