add some nan/inifite safety