refactoring jquery plugins