Implemeanted Proper undo stack handling