added checks and corrections for NaNs and misidentification in the first frame