Fix null pointer problem