Fixed silent crash that led to infinite loop