Protecting from null ref exceptions