preventing null pointer exceptions