fix destroy function