refactor event.js