fix the mem leak bug