optimize the update script