fix the memory leak problem