improvement of getInventory method in MongoDBConnector