properly - while(flag) instead of if(flag)