Fixed destroy function