fix double free error