Updated destroy function