update db more efficiently