add initial version of main loop