         registerRouteBranch(defaultRouteBranch)
     }
 
-    public func debug(msg: String) {
-        print("Router(\(msg)), branch.count=\(branchLastRecordedSegments.count)")
+    public func debugString(msg: String) -> String {
+        var lines: [String] = []
+        lines.append("Router(\(msg)), branch.count=\(branchLastRecordedSegments.count)")
         for (branchID, lastRecordedSegments) in branchLastRecordedSegments {
-            print("branch[\(branchID)].count=\(lastRecordedSegments.count)")
+            lines.append("branch[\(branchID)].count=\(lastRecordedSegments.count)")
             for index in 0..<lastRecordedSegments.count {
                 let recordedSegment = lastRecordedSegments[index]
                 let segmentIdentifier = recordedSegment.segmentIdentifier

                self.popRouteUsingRouteSegmentsToPop(newRecordedSegmentsToPop, sequenceCompletion: sequenceCompletion, popCompletion: popCompletion)
            case .Failure(_):
                // if popping this segment failed, do not attempt to pop the next one, just fail
                sequenceCompletion(.Failure(RoutingErrors.PresenterNotRegistered(recordedSegment.segmentIdentifier)))
                popCompletion()
            }
        }


        } else {
            let previousSequence: [Any] = updatedRecordedSegments.map { $0.segmentIdentifier }
            self.executeRouteSequence(previousSequence, append: false, routeBranch: defaultRouteBranch, completion: completion)
        }
    }
