replaced isnan for cvIsNan