Fix the memory leak