protecting against null pointer exceptions