Implement undo behaviour