variable name change, catch non-finite values in check_grad