converted to jQuery plugin