init main loop