writing to mongoDb