refactor(discovery): isolate functions