Fixing NaN issues