Refactor of script.