Fixing logic for upgrade.sh