memory leak bug fix