avoiding null pointer exceptions