diff --git a/src/Entity/Wishlist.php b/src/Entity/Wishlist.php
index 97924ccb743f29f8fd7af796b8b2be03fd9ec101..9c16360e90dd7fe7e5adfe93d8137a1594cb0313 100644
--- a/src/Entity/Wishlist.php
+++ b/src/Entity/Wishlist.php
@@ -125,7 +125,7 @@ class Wishlist
 
     public function getItemById(int $id){
         $itemsArray = (($this->items->toArray()))  ; 
-        for ($i = 0; $i < count($itemsArray); $i++) {
+        for ($i = 0; $i < sizeof($itemsArray); $i++) {
             $item = $itemsArray[$i];
             if ($item->getId() == $id ) {
                 return $item;
diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php
index e714b9fd2c22f8e7747f0b05ed93313b1cd3b89d..25c14b1ca74920c7e68b0ceffc135acebe3c5928 100644
--- a/src/Repository/WishlistRepository.php
+++ b/src/Repository/WishlistRepository.php
@@ -42,32 +42,61 @@ class WishlistRepository extends ServiceEntityRepository
             $wishlist->setDeadline($deadline);
             $this->getEntityManager()->flush();
         }
+        return $wishlist;
     }
 
 
 
     public function mostExpensiveList() {
         $wishlists  = $this->findAll() ; 
+        $rankings = array();
+        foreach ($wishlists as $wishlist) {
+            $total =  $wishlist->wishlistTotalPrice() ; 
+            
+            if (sizeof(($rankings)) < 3  ) {
+                $rankings[] = ['wishlist' => $wishlist, 'total' => $total];
+                usort($rankings, callback: function($a, $b) {return $a['total'] - $b['total'];});
+            } else {
+                for ($i = 0; $i < sizeof($rankings) ; $i++ ) {
+                    if ($rankings[i]['total'] < $total ) {
+                        $rankings[i] = ['wishlist' => $wishlist, 'total' => $total] ; 
+                    }
+                } 
 
-        
+            }
+            
+        }
+        $result = array() ; 
+        for ($i =  0 ; $i < sizeof($rankings) ; $i++ ) {
+            $result[] = $rankings[i]['wishlist'] ; 
+        }
+        return $result;
+    }
+
+
+    public function mostExpensiveItems() {
+        $wishlists = $this->findAll() ; 
+        $rankings = array();
         foreach ($wishlists as $wishlist) {
             $items = $wishlist->getItems();
-        }
+            foreach ($items as $item) {
+                if ($item->getPurchaseProof()) {
+                    if (sizeof(($rankings)) < 3  ) {
+                        $rankings[] = $item;
+                        usort( $rankings, function($a, $b) {return $a->getPrice() - $b->getPrice();});
+                    } else {
+                        for ($i = 0; $i < sizeof($rankings) ; $i++ ) {
+                            if ($rankings[i]->getPrice() < $item->getPrice() ) {
+                                $rankings[i] = $item ; 
+                            }
+                        } 
         
+                    }
+                }
+            }
 
-    }
-    
-    public function findTopWishlistsByValue(): array
-    {   
-        return $this->createQueryBuilder('u')
-            ->join('u.wishlist', 'w')
-            ->join('w.items', 'i')
-            ->where('i.isPurchased = true')
-            ->groupBy('w.id')
-            ->orderBy('SUM(i.price)', 'DESC')
-            ->setMaxResults(3)
-            ->getQuery()
-            ->getResult();
+        }
+        return $rankings;
     }
     //    /**
     //     * @return Wishlist[] Returns an array of Wishlist objects