fixed bug in & optimized uniq()