Fixed a bug in destroy() method