fix mem leak issue