fixed bug of inf and nan