Finished upgrade function