update script refactoring