added functionality to destroy function