     /// Append `newElement` to the array.
     public func append(_ newElement: UnderlyingCollection.Element) {
         lock.lock(); defer { lock.unlock() }
-        list.append(newElement)
-        let index = list.index(list.endIndex, offsetBy: -1)
-        subject.next(ObservableCollectionEvent(change: .inserts([index]), source: list))
+        collection.append(newElement)
+        let index = collection.index(collection.endIndex, offsetBy: -1)
+        subject.next(ObservableCollectionEvent(change: .inserts([index]), source: collection))
     }
     
     /// Insert `newElement` at index `i`.
     public func insert(_ newElement: UnderlyingCollection.Element, at index: UnderlyingCollection.Index) {
         lock.lock(); defer { lock.unlock() }
-        list.insert(newElement, at: index)
-        subject.next(ObservableCollectionEvent(change: .inserts([index]), source: list))
+        collection.insert(newElement, at: index)
+        subject.next(ObservableCollectionEvent(change: .inserts([index]), source: collection))
     }
     
     /// Insert elements `newElements` at index `i`.
     public func insert(contentsOf newElements: [UnderlyingCollection.Element], at index: UnderlyingCollection.Index) {
         lock.lock(); defer { lock.unlock() }
         for newElement in newElements.reversed() {
-            list.insert(newElement, at: index)
+            collection.insert(newElement, at: index)
         }
         
         let endIndex = offsetIndex(index, by: newElements.count)
         let indices = indexes(from: index, to: endIndex)
-        subject.next(ObservableCollectionEvent(change: .inserts(indices), source: list))
+        subject.next(ObservableCollectionEvent(change: .inserts(indices), source: collection))
     }
     
     /// Move the element at index `i` to index `toIndex`.
     public func moveItem(from fromIndex: UnderlyingCollection.Index, to toIndex: UnderlyingCollection.Index) {
         lock.lock(); defer { lock.unlock() }
-        let item = list.remove(at: fromIndex)
-        list.insert(item, at: toIndex)
-        subject.next(ObservableCollectionEvent(change: .move(fromIndex, toIndex), source: list))
+        let item = collection.remove(at: fromIndex)
+        collection.insert(item, at: toIndex)
+        subject.next(ObservableCollectionEvent(change: .move(fromIndex, toIndex), source: collection))
     }
     
     /// Remove and return the element at index i.
     @discardableResult
     public func remove(at index: UnderlyingCollection.Index) -> UnderlyingCollection.Element {
         lock.lock(); defer { lock.unlock() }
-        let element = list.remove(at: index)
-        subject.next(ObservableCollectionEvent(change: .deletes([index]), source: list))
+        let element = collection.remove(at: index)
+        subject.next(ObservableCollectionEvent(change: .deletes([index]), source: collection))
         return element
     }
     

        var indices: [UnderlyingCollection.Index] = [from]
        var i = from
        while i != to {
            list.formIndex(after: &i)
            indices.append(i)
        }
        return indices

extension MutableObservableCollection {
    public func replace(with list: UnderlyingCollection) {
        lock.lock(); defer { lock.unlock() }
        collection = list
        subject.next(ObservableCollectionEvent(change: .reset, source: collection))
    }
}

