add missing protection for potential null pointer