ensuring undo is always called before redo