Added check for duplicates