Refactor js into jquery