Scripts refactor