added ondestroy function