Error checking pointer instead of value