fix bug in autocommand's event handler