templateSelection append

Dear All, I would like to state number selected for a select muliselect. I’m using the code below. The code appaend, so if I got two options and choose both. I got the text below twice. How ca I prevent that?

	  templateSelection: function (data) {
		if (!data.id) { return data.text; }
		var selected = ($('#idselect5').val() || []).length;
		var total = $('option', $('#idselect5')).length;
		return "Selected " + selected + " of " + total;