fix upgrade when number of instances changed