Added check for duplicate names