Working, updating document in database and writing result back