converted to a jquery plugin