One last optimization for IsValid

the function Contains returns a bool, so if we just return it instead of
going into a conditional block of code we save some time.