add a isNaN check to the while loop
Merge pull request #1 from Caldwerl/NaN-check

add an isNaN check to the while loop