fixed the mem leak