Throw errors early in loops