refactor timeout with write event