Adding check before latestTrackingId assignment