 
         let components = path.unicodeScalars.split("/").map(String.init)
         var parameters: [String: String] = [:]
+
         let matched = searchForRoute(
             head: routesTrie,
-            components: components,
-            componentIndex: 0,
+            components: components.generate(),
             parameters: &parameters
         )
 


        return dictionary
    }
}
        }
    }

    func searchForRoute(head head: Trie<String, RouteType>, components: IndexingGenerator<[String]>, inout parameters: [String:String]) -> RouteType? {

        var components = components

        // if no more components, we hit the end of the path and 
        // may have matched something
        guard let component = components.next() else {
            return head.payload
        }

        // store each possible path (ie both a static and a parameter)
        // and then go through them all
        var paths = [Trie<String, RouteType>]()

        for child in head.children {

            // matched static
            if child.prefix == component {
                paths.append(child)
                continue
            }

            // matched parameter
            if child.prefix?.characters.first == ":" {
                paths.append(child)
                let param = String(child.prefix!.characters.dropFirst())
                parameters[param] = component
                continue
            }
        }

        // go through all the paths and recursively try to match them. if
        // any of them match, the route has been matched
        for path in paths {
            let matched = searchForRoute(head: path, components: components, parameters: &parameters)
            if let matched = matched { return matched }
        }

        // we went through all the possible paths and still found nothing. 404
        return nil
    }

    public func match(request: Request) -> RouteType? {
