improved write to mongodb process