added testing for NAN, found errors