Add main loop, error handling