Duplicate Entry when creating contact

Hi i am getting duplicate entry error when creating contact for customer with same name (but different number and email)

I checked code:

class Contact(Document):
	def autoname(self):
		# concat first and last name
		self.name = " ".join(filter(None,
			[cstr(self.get(f)).strip() for f in ["first_name", "last_name"]]))

		if frappe.db.exists("Contact", self.name):
			self.name = append_number_if_name_exists('Contact', self.name)

		# concat party name if reqd
		for link in self.links:
			self.name = self.name + '-' + link.link_name.strip()
			break

I thing that it should look like:

class Contact(Document):
	def autoname(self):
		# concat first and last name
		self.name = " ".join(filter(None,
			[cstr(self.get(f)).strip() for f in ["first_name", "last_name"]]))

		# concat party name if reqd
		for link in self.links:
			self.name = self.name + '-' + link.link_name.strip()
			break

        if frappe.db.exists("Contact", self.name):
			self.name = append_number_if_name_exists('Contact', self.name)

Because error is showing when link exist for same customer two times with same name, but what if customer has two or more contact details.

ERPNext: v11.1.21 (master)
Frappe Framework: v11.1.22 (master)