Clean code
Handle infinity and NaN