         destroyVirtualOutputPort()
     }
 
-    /// Closes the virtual input port, if created one already.
+    /// Closes the virtuals input ports, if created one already.
     ///
-    /// - Returns: Returns true if virtual input closed.
+    /// - Returns: Returns true if virtuals inputs closed.
     ///
     @discardableResult public func destroyVirtualInputPort() -> Bool {
-        if virtualInputs[0] != 0 {
-            if MIDIEndpointDispose(virtualInputs[0]) == noErr {
-                virtualInputs[0] = 0
-                return true
+        if virtualInputs != [0] {
+            for (index, virtualInput) in virtualInputs.enumerated() {
+                guard MIDIEndpointDispose(virtualInput) == noErr else {return false}
+                virtualInputs.remove(at: index)
             }
-        }
+            virtualInputs[0] = 0
+            return true
+            }
         return false
     }
 
-    /// Closes the virtual output port, if created one already.
+    /// Closes the virtuals output ports, if created one already.
     ///
-    /// - Returns: Returns true if virtual output closed.
+    /// - Returns: Returns true if virtuals outputs closed.
     ///
     @discardableResult public func destroyVirtualOutputPort() -> Bool {
-        if virtualOutputs[0] != 0 {
-            if MIDIEndpointDispose(virtualOutputs[0]) == noErr {
-                virtualOutputs[0] = 0
-                return true
+        if virtualOutputs != [0] {
+            for (index, virtualOutput) in virtualOutputs.enumerated() {
+                guard MIDIEndpointDispose(virtualOutput) == noErr else {return false}
+                virtualOutputs.remove(at: index)
             }
+            virtualOutputs[0] = 0
+            return true
         }
         return false
     }

        }
    }

    /// Create multiple virtual MIDI output ports
    public func createMultipleVirtualOutputPorts(numberOfPorts: Int = 2, _ uniqueIDs: [Int32]? = nil, names: [String]? = nil) {
        destroyVirtualOutputPort()
        var unnamedPortIndex = 1
        var unIDPortIndex: Int32 = 0
        for virtualPortIndex in 1...numberOfPorts {
            var virtualPortName: String
            var uniqueID: Int32

            if names?[virtualPortIndex] != nil {
                virtualPortName = names![virtualPortIndex]

    //      * Support hidden uuid generation so the caller can worry about less
    //


     /// Create set of virtual input and output MIDI ports
    public func createVirtualPorts(numberOfPort: Int = 1, _ uniqueIDs: [Int32]? = nil, names: [String]? = nil) {
        Log("Creating \(numberOfPort) virtual input and output ports", log: OSLog.midi)
        destroyVirtualPorts()
        createMultipleVirtualInputPorts(numberOfPort: numberOfPort, names: names)
        createMultipleVirtualOutputPorts(numberOfPort: numberOfPort, names: names)
    }

    /// Create virtual MIDI input ports
    public func createVirtualInputPorts(numberOfPort: Int = 1, _ uniqueIDs: [Int32]? = nil, names: [String]? = nil) {
        destroyVirtualInputPort()
        guard numberOfPort < 0 else { Log("Error: Number of port to create can't be less than one)",log: OSLog.midi, type: .error)}

        var unnamedPortIndex = 1
        var unIDPortIndex: Int32 = 0
        for virtualPortIndex in 0...numberOfPorts - 1 {
            var virtualPortName: String
            var uniqueID: Int32
            virtualInputs.append(0)

            if let portName = names?[virtualPortIndex] {
                virtualPortName = portName
            } else {
               virtualPortName = String("\(clientName) \(unnamedPortIndex)")
               unnamedPortIndex += 1
           }

            if let portID = uniqueIDs?[virtualPortIndex] {
                uniqueID = portID
            } else {
                uniqueID = 2_000_001 + unIDPortIndex
                unIDPortIndex += 2
