add main loop