Trying to fix some hanging for loops