added code to destroy the pointer and comments