Implemented alternative uniquifying algorithm.