fixed memory leak control