add comments for main loop functions to create a big picture of what is going on