more efficient error code checking