added checking for duplicates in the same class