Jquery plugin and refactoring