Refactor script file