updated destroy function