Updated IsValid() method.