modified to remove duplicates in category