Fixed the memory leak