optimized order of validity checks