Endless loop fix