                     string += "=\(value)"
                 }
 
-                if valueIndex != query[key].values.count - 1 {
+                if valueIndex != query[key]!.count - 1 {
                     string += "&"
                 }
             }

        if u.error == 1 {
            throw URIError.invalidURI
        }
        
        if u.field_set & 1 != 0 {
            let string = URI.getSubstring(string, start: u.scheme_start, end: u.scheme_end)
            scheme = try String(percentEncoded: string)

            string += "?"
        }

        for (offset: queryIndex, element: key) in query.keys.sorted().enumerated() {
            for (offset: valueIndex, element: value) in query[key]!.enumerated() {
                string += "\(key)"

                if let value = value {
                    string += "=\(value)"
                }

                if valueIndex != query[key]!.count - 1 {
                    string += "&"
                }
            }
