Fixed a frustrating NaN bug