         SecTrustSetPolicies(trust,policy)
         if self.usePublicKeys {
             if let keys = self.pubKeys {
-                var trustedCount = 0
                 let serverPubKeys = publicKeyChainForTrust(trust)
                 for serverKey in serverPubKeys as [AnyObject] {
                     for key in keys as [AnyObject] {
                         if serverKey.isEqual(key) {
-                            trustedCount++
-                            break
+                            return true
                         }
                     }
                 }
-                if trustedCount == serverPubKeys.count {
-                    return true
-                }
             }
         } else if let certs = self.certificates {
             let serverCerts = certificateChainForTrust(trust)
-            var collect = Array<SecCertificate>()
+            var collect = [SecCertificate]()
             for cert in certs {
                 collect.append(SecCertificateCreateWithData(nil,cert)!)
             }

                sslContextOut = CFWriteStreamCopyProperty(outputStream, kCFStreamPropertySSLContext) as! SSLContextRef? {
                    let resIn = SSLSetEnabledCiphers(sslContextIn, cipherSuites, cipherSuites.count)
                    let resOut = SSLSetEnabledCiphers(sslContextOut, cipherSuites, cipherSuites.count)
                    if (resIn != errSecSuccess) {
                        let error = self.errorWithDetail("Error setting ingoing cypher suites", code: UInt16(resIn))
                        disconnectStream(error)
                        return
                    }
                    if (resOut != errSecSuccess) {
                        let error = self.errorWithDetail("Error setting outgoing cypher suites", code: UInt16(resOut))
                        disconnectStream(error)
                        return

    
    ///Create an error
    private func errorWithDetail(detail: String, code: UInt16) -> NSError {
        var details = [String: String]()
        details[NSLocalizedDescriptionKey] =  detail
        return NSError(domain: WebSocket.ErrorDomain, code: Int(code), userInfo: details)
    }
