Handled the NaN errors

--Divide by 0 error handled