Main loop logic