Fixing an issue with NaN.
Fixing an issue with NaN in the output.