Added failsafe to iterations

now stops after 100 iterations