Refactor event binding