Fixed the memory leak issue