Fix null pointer error