Fixed bug when free the memory