Refactor update_submodules function