                     return
                 }
 
-                for endpoint in endpoints.values {
+                var endpointsRef: [MIDIEndpointRef] = []
+
+                if let endpointsUIDS = endpointsUIDs {
+                    for endpointUID in endpointsUIDS {
+                        if let endpoint = endpoints[endpointUID] {endpointsRef.append(endpoint)}
+                    }
+                } else {
+                    endpointsRef = Array(endpoints.values)
+                }
+
+                for endpoint in endpointsRef {
                     let result = MIDISend(outputPort, endpoint, packetListPointer)
                     if result != noErr {
                         Log("error sending midi: \(result)", log: OSLog.midi, type: .error)
                     }
                 }
 
-                if virtualOutputs[0] != 0 {
-                    MIDIReceived(virtualOutputs[0], packetListPointer)
+                if virtualOutputs != [0] {
+                    virtualOutputs.forEach {MIDIReceived($0, packetListPointer)}
                 }
             }
         }

    public func sendNoteOffMessageWithTime(noteNumber: MIDINoteNumber,
                                           velocity: MIDIVelocity,
                                           channel: MIDIChannel = 0,
                                           time: MIDITimeStamp = 0) {
        let noteCommand: MIDIByte = MIDIByte(0x80) + channel
        let message: [MIDIByte] = [noteCommand, noteNumber, velocity]
        self.sendMessageWithTime(message, time: time)
    }

    /// Send Message with data with timestamp

    ///   - channel: MIDI Channel (default: 0)
    public func sendNoteOffMessage(noteNumber: MIDINoteNumber,
                                   velocity: MIDIVelocity,
                                   channel: MIDIChannel = 0,
                                   endpointsUIDs: [MIDIUniqueID]? = nil) {
        let noteCommand: MIDIByte = noteOffByte + channel
        let message: [MIDIByte] = [noteCommand, noteNumber, velocity]
        self.sendMessage(message, endpointsUIDs: endpointsUIDs)
    }

    /// Send a Continuous Controller message
