Added a main loop