Optimization for while(true)