write resizeInstances method