js to jquery refactor