fix main loop
bugfix