refact script