Refactor js.