Fix null pointer exception