Fixing prevent_upgrade logic