Fixed code so it works for finding duplicates.