Main loop creation