fixed the nullptr return case