changed for(;;) to do-while, still probs with ATOMIC