commiting the undo function