Fix null pointer use