runs the main loop after initialising