Made undo a little more functional