Refactored the code and updated to driver interface and mongo driver.