fix the memory leak