while != 0 main loop