Attempt to fix main loop