add jquery plugin and litle refactoring