fix upgrade bugs