Jquery menu plugin messes up other jquery scripts

I have the following jquery plugin that I use to create a menu system.

jQuery.fn.initMenu = function() {

return $(this).each(function() {
var $menu = $(this);
	
	// Set the container's height
	$menu.find('.sub').show();
	$menu.parent().height($menu.height() + 10);
	$menu.find('.sub').hide();

	// Append arrow to submenu items
	$menu.find('li:has(ul)').each(function() {
		$(this).children('a').append("<span class='arrow'>»</span>");
	});
	$menu.find('.sub').hide();
	
	// The main part
	$menu.find('li a').click(function(e) {
		
		e.stopImmediatePropagation();
		var $submenu = $(this).next(), $this = $(this);
		
		if($menu.hasClass('noaccordion')) {
			if($submenu.length == 0) {
				window.location.href = this.href;
			}
			$submenu.slideToggle('normal');
			return false;
		} else {
			// Using accordeon
			if($submenu.hasClass('sub') && $submenu.is(':visible')) {
				// If already visible, slide up
				if($menu.hasClass('collapsible')) {
					$menu.find('.sub:visible').slideUp('normal');
					return false;
				}
				return false;
			} else if($submenu.hasClass('sub') && !$submenu.is(':visible')) {
				// If not visible, slide down
				$menu.find('.sub:visible').slideUp('normal');
				$submenu.slideDown('normal');
				return false;
			}
		}
	});
	
});

};

The line of code
return $(this).each(function() {
messes up a couple of jquery scripts that I use. I think it is because many of the scripts are named function(). Does anyone know a way around this or can I alter this script so I do not have to use return $(this).each(function() {
If I comment out this line of code the rest of my page works fine, but my menu is broken. thanks in advance.

That is a fundamental part of jQuery that allows method chaining. It’s something that virtually all jQuery plugins do.

Show us a link to a version of your page that is misbehaving, and we’ll work out what the real conflict is, and potentially even come up with a viable solution for you.

Thanks but I figured it out.