extracted duplicates method

Extracted the code for checking for duplicate search results so that it
becomes re-usable for further searches