Reimplemented database so that [Transaction] update is atomic