Fix null pointer reference