fix inverted logic for valid