Possible fix for loop