closer to algorithm; clearer numValid