Attempting to fix infinite loops