redesigning mainloop and added function to improv structure