Guard against null pointer exceptions