Refactored duplicate code

Extracted Mongo Connection to common function.
Updated naming conventions
Removed redundant code