Fix null pointer exeption