minor changes
updated isValid() method