fixed memory leak because of incorrect delete.