Converted into a jquery plugin