fixing isValid() definition