exercise 13-3: add "valid" member function