fix double free issue