         }
     }
 
-    if let factor = parse(url.host, with:factorParser(parse(queryDictionary[kQueryCounterKey], with:counterParser), parse(queryDictionary[kQueryPeriodKey], with:periodParser))).defaultTo(nil) {
+    if let factor = parsed(url.host, with: factorParser(
+        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 algorithm = parse(queryDictionary[kQueryAlgorithmKey], with:algorithmFromString).defaultTo(.SHA1) {
-                if let digits = parse(queryDictionary[kQueryDigitsKey], with:{ $0.toInt() }).defaultTo(6) {
+            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)
 
                     if core.isValid {

    return .Default
}

enum ParsedResult<T> {
    case Result(T), Default, Error


    return nil
}

func factorParser(parsedCounter: UInt64?, parsedPeriod: NSTimeInterval?) -> (string: String) -> Generator.Factor? {
    return { string in
        if string == FactorCounterString {
            if let counter = parsedCounter {
                return .Counter(counter)
            }
        } else if string == FactorTimerString {
            if let period =  parsedPeriod {
                return .Timer(period: period)
            }
        }
