     }
 
     open func removeObject(at idx: Int) {
+        _validateSubscript(idx)
         _storage.remove(_orderedStorage[idx])
         _orderedStorage.remove(at: idx)
     }
 
     open func replaceObject(at idx: Int, with obj: Any) {
-        guard idx < count && idx >= 0 else {
-            fatalError("\(self): Index out of bounds")
-        }
-        
         let value = __SwiftValue.store(obj)
         let objectToReplace = __SwiftValue.store(object(at: idx))
         _orderedStorage[idx] = value

open class NSMutableOrderedSet : NSOrderedSet {
    
    open func insert(_ object: Any, at idx: Int) {
        guard idx <= count && idx >= 0 else {
            fatalError("\(self): Index out of bounds")
        }

        let value = __SwiftValue.store(object)


        guard aCoder.allowsKeyedCoding else {
            preconditionFailure("Unkeyed coding is unsupported.")
        }
        for idx in _indices {
            aCoder.encode(__SwiftValue.store(self.object(at: idx)), forKey:"NS.object.\(idx)")
        }
    }
