Corrected pointer check
Removed dead code