infinite loop fixed