timed main loop