added randomize method and fixed collaspeDuplicates