General debugging for undo function