jquery refactored and working