dead loop fixed