Fixed upgrade script