fix null pointer exceptions