Moved external query count update code to within the URL retrieval function, to correctly count multiple attempts