             case .NamedValues(let namedValues):
                 return sqliteArgumentNames.map { argumentName in
                     if let argumentName = argumentName {
-                        for (name, value) in namedValues where name == argumentName {
+                        if let value = namedValues[argumentName] {
                             return (argumentName, value?.databaseValue ?? .Null)
+                        } else {
+                            return (argumentName, nil)
                         }
-                        return (argumentName, nil)
                     }
                     return (nil, nil)
                 }

            }
            break
        case .NamedValues(let namedValues):
            // TODO: test
            for (index, argumentName) in sqliteArgumentNames.enumerate() {
                if let argumentName = argumentName {
                    for (name, value) in namedValues where name == argumentName {
                        try! bindDatabaseValue(value?.databaseValue ?? .Null, atIndex: Int32(index + 1))
                        break
                    }
                }
            }
        }

    
    enum Kind {
        case Values([DatabaseValueConvertible?])
        case NamedValues(ShortDictionary<String, DatabaseValueConvertible?>)
    }
    
    let kind: Kind
