seems like if this line is reached, it will loop forever (that is, if val is NaN now, won't it still be NaN in the recursive call to calcVal?).. I don't think we need to check for NaN. I'm not sure why that would ever happen.