Do you have an ITI? If not, then maybe the whole routine is running twice without you noticing.
Add print commands
Check you are using the latest code