Removing duplicates using naive solution