fix bug and add event support