scripts refactoring