destroy changed to prevent memory leak