Better upgrade function