atomized the main loop