Minor, but this would read a little better as while(!terminated) without the break below