Simple "pulse" plugin needs closure?

Simple "pulse" plugin needs closure?

 I'm trying to create a very simple plugin to control the pulse (fadeIn()/fadeOut()) effect and use a callback. The pulse itself works, but the callback doesn't. I'm not sure what i'm doing wrong?

   
  1.  (function($){ $.fn.pulse = function(options) { return this.each(function(){ var $this = $(this), settings = $.extend({}, $.fn.pulse.defaults, options); $this .fadeIn(settings.speed,function(){ for(var n=settings.count-1; n>=0; n--){ $(this) .fadeOut(settings.speed) .fadeIn(settings.speed,function(){ if(n == 0){ settings.callback(); // not working! } }); } }); }); }; $.fn.pulse.defaults = { count : 3, speed : 'fast', callback : function(){alert('Done!')} }; })(jQuery);