Extracted stuff in main into get_thread() and update()