Are you sure the problem might be that the validation loop just takes some time, which might look like the script is hanging? 
I’ve added a print statement into the validation method and see it’s quite slow.