unable to debug. Getting NaN as calculation