Convert to jQuery plugin