corrected error with data which was giving undefined and NaN error

corrected error with data which was giving undefined and NaN error