endless loop fixed