Fixing a flaw in  such that duplicate values aren't created