Do you remember to initialize ID in your texture record? before the if loop?