update logic. refactor threading.