added code to destroy the pointer and comments

added comment