replace null pointer check functions by methods