fixed memory releasing bug caused by previous commit