Upgrade script fixed