implemented undo feature