Refactor update_commit method