fix main loop
restructure to take burden from VTE