fixed memory deallocation error