converted into jquery plugin