Use the search string, not the hash. Chunked up the code into smaller functions.