      - parameter object: The object to be removed.
      */
     @discardableResult public mutating func remove(object: T)-> T? {
-        guard let index = weakReferecesContainers.index(where: { $0.weakReference === object as AnyObject }) else { return nil }
-        return weakReferecesContainers.remove(at: index).weakReference as? T
+        var result: T?
+        synced(lockObject) {
+            guard let index = weakReferecesContainers.index(where: { $0.weakReference === object as AnyObject }) else { return }
+            result = weakReferecesContainers.remove(at: index).weakReference as? T
+        }
+        
+        return result
     }
     
     /**

     does not have strong references to the object.
     */
    public mutating func add(object: T) {
        guard weakReferecesContainers.filter({ $0.weakReference === object as AnyObject}).count == 0 else { return }
        
        let container = LNZWeakContainer(weakReference: object as AnyObject)
        weakReferecesContainers.append(container)
    }
    
    /**

     */
    public mutating func execute(_ closure: ((_ object: T) throws -> Void)) rethrows {
        cleanup()
        try synced(lockObject) {
            try weakReferecesContainers.forEach { (weakContainer) in
                guard let weakReference = weakContainer.weakReference as? T else { return }
                try closure(weakReference)
            }
        }
    }
    
    ///Clean all the weak objects that are now nil
    internal mutating func cleanup() {
        synced(lockObject) {
            while let index = weakReferecesContainers.index(where: { $0.weakReference == nil }) {
                weakReferecesContainers.remove(at: index)
                if index < currentIndex {
                    currentIndex -= 1
                }
            }
        }
    }
