Fix NaN

In some cases this methos did return NaN when should return infinity -
this has been fixed