Undo function

Needs debugging