fix bugs release memory