Fix max error breaking of loop.
Fix max error breaking of loop.

materialsproject/custodian,specter119/custodian,alberthxf/custodian,materialsproject/custodian,davidwaroquiers/custodian,xhqu1981/custodian,specter119/custodian,specter119/custodian,materialsproject/custodian