replace isNaN with isFinite

isNaN treats Infinity as a number