refactor js to commonJS