proper nan and -inf removal