replace all endless for loops by while