improve and simplify looping structures

I think this "exit" is usefull, no?