Fix null pointer deference