rearranged method to access MongoDB