Undo with flag but seems quite buggy at the moment