refactoring to get Jquery plugin