Making a main loop