fixed bug in undo event handler