       return anchors.compactMap({ try? $0.absUrl("href") }).compactMap(URL.init(string:))
     }
 
-    find(word: wordToSearch, from: document)
-    collectLinks(from: document).forEach { pagesToVisit.insert($0) }
+    find(word: wordToSearch, from: webpage)
+    collectLinks(from: webpage).forEach { pagesToVisit.insert($0) }
   }
 }

  /// Parses the given document.
  ///
  /// - Parameters:
  ///   - document: The content to parse.
  ///   - url: The url associated with the document.
  func parse(document: String, url: URL) {
    func find(word: String, from document: String) {
      guard document.contains(word) else { return }
      delegate?.crawler(self, didFindWordAt: url)

      defer { self?.crawl() }
      guard
        let data = data,
        let webpage = String(data: data, encoding: .utf8) else { return }
      self?.parse(webpage, url: url)
    }

    delegate?.crawler(self, willVisitUrl: url)
