Rewrite while(true) loops