added undo (ctrl-z) functionality