fix bug in updateMaxInstanceNum