converting to jquery plugin