main loop runs