fixed potential null pointer exceptions