Updated the recursion for link discovery