fixed bugs in undo
fixed bug in undo