added support for destroy function, will be used before unmounting