refactor for smarter batch updates