refactoring, method to find duplicates modified and spec added