Fixed upgrade bug