Update code to fix upgrade error