Refactores sequencial execution of db operations on the same document