refactoring jquery plugin