diff --git image_caption.js image_caption.js
index 33ba19d..1afc656 100644
--- image_caption.js
+++ image_caption.js
@@ -1,13 +1,16 @@
 /*$Id: image_caption.js,v 1.2 2008-03-07 05:46:23 davidwhthomas Exp $*/
+
 $(document).ready(function(){
   $("img.caption").each(function(i) {
-    var imgwidth = $(this).width();
-    var imgheight = $(this).height();
-    var captiontext = $(this).attr('title');
-    var alignment = $(this).attr('align');
-    $(this).attr({align:""});
-    $(this).wrap("<div class=\"image-caption-container\" style=\"float:" + alignment + "\"></div>");
-    $(this).parent().width(imgwidth);
-    $(this).parent().append("<div class=\"image-caption\">" + captiontext + "</div>");
+    var $this = $(this),
+        imgwidth = $this.width(),
+        imgheight = $this.height(),
+        captiontext = $this.attr('title'),
+        alignment = $this.attr('align');
+    $this.removeAttr('align')
+      .wrap('<div class="image-caption-container" style="float:' + alignment + '"></div>')
+      .parent()
+      .width(imgwidth)
+      .append('<div class="image-caption">' + captiontext + '</div>');
   });
-});
\ No newline at end of file
+});
