         parsed(queryDictionary[kQueryCounterKey], with: counterParser, defaultTo: 0),
         parsed(queryDictionary[kQueryPeriodKey], with: periodParser, defaultTo: 30)
         ), defaultTo: nil) {
-        if let secret = parse(queryDictionary[kQuerySecretKey], with:{ MF_Base32Codec.dataFromBase32String($0) }).overrideWith(externalSecret) {
+            if let secret = parsed(queryDictionary[kQuerySecretKey], with: { MF_Base32Codec.dataFromBase32String($0) }, defaultTo: externalSecret, preferDefault: true) {
             if let algorithm = parsed(queryDictionary[kQueryAlgorithmKey], with: algorithmFromString, defaultTo: .SHA1) {
                 if let digits = parsed(queryDictionary[kQueryDigitsKey], with: { $0.toInt() }, defaultTo: 6) {
                     let core = Generator(factor: factor, secret: secret, algorithm: algorithm, digits: digits)


// MARK: Parsing Helpers

func parse<P, T>(item: P?, with parser: (P -> T?)) -> ParsedResult<T> {
    if let concrete = item {
        if let value = parser(concrete) {
            return .Result(value)
        }
        return .Error
    }
    return .Default
}

func parsed<P, T>(item: P?, with parser: (P -> T?), defaultTo def: T? = nil) -> T? {
    if let concrete = item {
        if let value = parser(concrete) {
            return value

        return nil
    }
    return def
}

func counterParser(string: String) -> UInt64? {
