destroy function working in all browsers