hooked up the main loop