Pull common stdlib checking code into a method