Thanks! I think you are correct, after the successful completion I added that statement as a safety before deleting all other previous attempts. Reading this code again it really could have used the data more efficiently to predict the correct ID faster, but if I remember correctly it didn't take very long to run so I never made another attempt.
The hardcoded ID in your code was added after it was generated just before deleting everything else, right? Otherwise I'm stumped.