finish fixing memory leak using destroy