         {
             if (value == null) throw new ArgumentError("value is null");
 
-            if (_bounded && _inUse.length >= _maxSize)
+            if (_bounded && _inUseCount >= _maxSize)
             {
                 _callbacks.push(value);
             }

            else
            {
                reclaimFunction(instance);
                _available.push(instance);

                var f:Function;
                if (_bounded)
                {
                    while (_inUse.length < _maxSize && (f = _callbacks.shift()))
                    {
                        f(getObject());
                    }


        public function getObject():Object
        {
            if (_bounded && _inUseCount >= _maxSize)
            {
                if (maxSizeException)
                {
                    throw new IllegalOperationError("ObjectPool size exceeded maxSize");
                }
                return _instantiateFunction();
            }

            var instance:Object;
            for (instance in _available)
            {
                break;
            }
            
            if (instance)
            {
                delete _available[instance];
                _availableCount--;
            }
            else
            {
                instance = _instantiateFunction();
            }
            
            _inUse[instance] = null;
            _inUseCount++;
            return instance;
        }

