Added writing to mongodb