Did some testing fixed some bugs in the undo function