Added isValid() method.