please, replace while(1) with for(;;) to avoid warnings from some compilers