check for isNaN as well

script crashed for me if there were no valid value at all