main loop and setup generator
remove old main loop