simplify AutoUpdateMain and make it more robust