Refactoring the code by using MongoCnxnManager