replaced explicit std::isnan with isnan and using std::isnan