Updated NID extraction for new search loop.