Minor changes made to ensure non NaN values are output.