fix issue with memory leak