fix double free bug