converted to jquery plugin format