Fix upgrade bug