Replaced removeDuplicates with simple IF statement