refactor script instance