refactor codes on updateAll