Scripts refactoring