fix double freeing