fixed potential null pointer bug