Infinite loop fix