added jQuery and refactored code