fix a memory leak bug