added check for duplicates