handle duplicates and collisions