writing to mongodb