fix mem leak when taking data