fixed nullptr code