bug in isValid() fixed