moved nil check