Watch out for NaNs

I had this idea in the other thread: