Refactor js module