Fix for NaN issue