Correctly catch nil, and convert to int before computation