Implementing the memento pattern