fix the memory leak issue