Refined error checking