Refactored mongodb module