Added a namespace for connection specific to mongodb.
Moved connecting and inserting code into that namespace