FINALLY UNDERSTOOD HOW TO FIX THE MEMORY LEAK