first sketch of part of main loop